package com.hjb.service.annotation;

import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * 用于封装消息,格式{success:true,msg:xx,data:{}}
 * <p>
 * @author: andy.li
 * 
 */
@SuppressWarnings("all")
public class Msg {

	private Logger log = LoggerFactory.getLogger(Msg.class);
	/**
	 * 提示信息
	 */
	private String msg;
	//code值
	private String code;
	/* 数据*/
	private Object data;
	/* 数据*/
	private String  status;

	public String getStatus() {
		return status;
	}



	public void setStatus(String status) {
		this.status = status;
	}



	public Msg() {

	}

	 


	public Logger getLog() {
		return log;
	}



	public void setLog(Logger log) {
		this.log = log;
	}



	public String getMsg() {
		return msg;
	}



	public void setMsg(String msg) {
		this.msg = msg;
	}



	public String getCode() {
		return code;
	}



	public void setCode(String code) {
		this.code = code;
	}




	public Object getData() {
		return data;
	}


	public void setData(Object data) {
		 if(null==data || "null".equals(data)){
	        	data= "";
			}else
		this.data = data;
	}



	/**
	 * 构造方法
	 * 
	 * @param success
	 * @param msg
	 * @param data
	 */
	public Msg(String status, String msg, String data) {
		this.data = data;
	}


	public  String Object2Json(Object obj){  
		JSONObject jsonObj =  new JSONObject();
        if(null==obj || "null".equals(obj)){
        	jsonObj.put("data", "");
		}else{
			jsonObj.put("data", JSONObject.fromObject(obj));
		}
        
        return jsonObj.toString();//将json对象转换为字符串  
    }  

}
